package com.seadragon.app.ksr.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

//@AnalyzerDef(name = "officeanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
//	@TokenFilterDef(factory = LowerCaseFilterFactory.class),
//	@TokenFilterDef(factory = StopFilterFactory.class, params = {
//			@Parameter(name = "words", value = "stopwords.txt"),
//			@Parameter(name = "ignoreCase", value = "true") }),
//	@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = { @Parameter(name = "language", value = "English") }) })
//@Indexed(index = "Office")
@Entity
@Table(name="OFFICE", schema="STAGING")
public class Office {
	@Id
	@Column(name = "ID")
//	@DocumentId
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "OFFICEIDSEQ")
	@SequenceGenerator(name = "OFFICEIDSEQ", sequenceName = "STAGING.OFFICE_ID_SEQ", schema="STAGING")	
	private long id;

	@Column(name="PHONE_NUMBER")
	private String phoneNumber;

//	@IndexedEmbedded
	@OneToOne(cascade=CascadeType.PERSIST)
	@JoinColumn(name="ADDRESS_ID")
	private Address address;
	
//	@IndexedEmbedded
	@ManyToOne
	@JoinColumn(name="BUSINESS_ID")
	private Business business;

	@Column(name="EMAIL_ADDRESS")
	private String emailAddress;

	@Column(name="DESCRIPTION", length = 2048)
//	@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
	private String description;

	@Column(name="SPECIALTY")
//	@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
	private String specialty;
	
//	@OneToMany(mappedBy="office", cascade=CascadeType.PERSIST)
//	@IndexedEmbedded
//	private List<Review> reviews;
	
	@Column(name="PRICE_RANGE")
//	@Fields({
//		@Field(name="price_range", index = Index.YES, analyze = Analyze.NO, store = Store.NO),
//	})
//	@NumericFields({
//		@NumericField(forField="price_range")
//	})
	private int priceRange;
	
	@Column(name="RATING")
//	@Fields({
//		@Field(name="rating", index = Index.YES, analyze = Analyze.NO, store = Store.NO),
//		@Field(name="rating_facet", index = Index.YES, analyze = Analyze.NO, store = Store.NO)
//	})
//	@NumericFields({
//		@NumericField(forField="rating")
//	})
	private int rating;
	
	@Column(name="PRICE")
//	@Fields({
//		@Field(name="price", index = Index.YES, analyze = Analyze.NO, store = Store.NO),
//		@Field(name="price_facet", index = Index.YES, analyze = Analyze.NO, store = Store.NO)
//	})
//	@NumericFields({
//		@NumericField(forField="price")
//	})
	private int price;
	
	@Column(name="REVIEW_COUNT")
//	@Field(index = Index.YES, analyze = Analyze.NO, store = Store.NO)
//	@NumericField
	private int reviewCount;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Business getBusiness() {
		return business;
	}

	public void setBusiness(Business business) {
		this.business = business;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	public String getSpecialty() {
		return specialty;
	}

	public void setSpecialty(String specialty) {
		this.specialty = specialty;
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getReviewCount() {
		return reviewCount;
	}

	public void setReviewCount(int reviewCount) {
		this.reviewCount = reviewCount;
	}
	
	public void increaseReviewCount(int count){
		this.reviewCount += count;
	}

	public int getPriceRange() {
		return priceRange;
	}

	public void setPriceRange(int priceRange) {
		this.priceRange = priceRange;
	}
}
